package psd;

import psd.RegRecord.LookKinkHow;


class Person {
	public int age;
	
	
	public boolean noPrimary;

/**
	 * @return the age
	 */
	public int getAge() {
		return age;
	}

	/**
	 * @param age the age to set
	 */
	public void setAge(int age) {
		this.age = age;
	}

	/**
	 * @return the first
	 */
	public String getFirst() {
		return first;
	}

	/**
	 * @param first the first to set
	 */
	public void setName(String first, String last) {
		this.first = first;
		this.last = last;
	}

	/**
	 * @return the maxAge
	 */
	public int getMaxAge() {
		return maxAge;
	}

	/**
	 * @param maxAge the maxAge to set
	 */
	public void setMaxAge(int maxAge) {
		this.maxAge = maxAge;
	}

	/**
	 * @return the minAge
	 */
	public int getMinAge() {
		return minAge;
	}

	/**
	 * @param minAge the minAge to set
	 */
	public void setMinAge(int minAge) {
		this.minAge = minAge;
	}

	/**
	 * @return the kinky
	 */
	public boolean isKinky() {
		return kinky;
	}

	/**
	 * @param kinky the kinky to set
	 */
	public void setKinky(boolean kinky) {
		this.kinky = kinky;
	}

	//	public int manActive = UNKNOWN;  // in case of group, are they the ones wanting action?
//	public int womanActive = UNKNOWN;
	public String first;
	public String last;

	public boolean man;
	public boolean woman;
	public boolean transM;
	public boolean transW;
	public boolean GQ;

	public boolean lookNone;
	public boolean lookW;
	public boolean lookGQ;
	public boolean lookM;
	public boolean lookTM;
	public boolean lookTW;

	public int maxAge;
	public int minAge;
	public LookKinkHow lookKink = LookKinkHow.EITHER;
	public boolean kinky;

	public boolean inactive() {
		return lookNone;
	}

	public boolean mutual( Person who ) {
		return (willDate( who ) > 0) && (who.willDate( this ) > 0); 
	}


	public String toString() {
		return toString( false );
	}
	
	String genderString() {
		String s = "";
		if ( man ) { s += "M"; }
		if ( transM ) { s += "*"; }
		if ( woman ) { s += "W"; }
		if ( transW) { s += "*"; }
		//s = s.substring(0, s.length() - 1 );
		if ( GQ ) { s += "!"; }
	//	if ( s.equals( "" ) ) { s = "none"; }
		
		return s;
	}

	String genderDesc() {
		String s = "";
		if ( man ) { s += "man/"; }
		if ( transM ) { s += "trans man/"; }
		if ( woman ) { s += "woman/"; }
		if ( transW) { s += "trans woman/"; }
		if ( !s.equals("") ) {
			s = s.substring(0, s.length()-1);
		}
		if ( GQ ) { s += " gender queer"; }
	//	if ( s.equals( "" ) ) { s = "none"; }
		if ( s.equals("")) { s = " without gender ID "; }
		
		return s.trim();
	}
	String genderLookDesc() {
		String s = "";
		if ( lookM ) { s += "men/"; }
		if ( lookTM ) { s += "trans men/"; }
	//	s += "|";
		if ( lookW ) { s += "women/"; }
		if ( lookTW) { s += "trans women/"; }
		if ( lookGQ ) { s += "gender-queers/"; }
		if ( lookNone ) { s += "none/"; }
		
		if ( s =="" ) {
			s = "nothing";
		} else {
			s = s.substring(0, s.length() - 1 );
		}
		
	//	if ( s.equals( "|" ) ) { s = ""; }
		return s;
	}

	String genderLookString() {
		String s = "";
		if ( lookM ) { s += "M"; }
		if ( lookTM ) { s += "*"; }
	//	s += "|";
		if ( lookW ) { s += "W"; }
		if ( lookTW) { s += "*"; }
		if ( lookGQ ) { s += "!"; }
		if ( lookNone ) { s += "none"; }
		
	//	if ( s.equals( "|" ) ) { s = ""; }
		return s;
	}
	
	public String toString( boolean write_comments_flag ) {

		String outputString = "";

		if ( write_comments_flag ) {
			outputString += first+ "," + last + ",";
		}

		outputString += WU.yesBlank(man) //+ "," + yesNoBlank(manActive)
		+ "," + WU.yesBlank(woman) //+ "," + yesNoBlank(womanActive)
		+ "," + WU.yesBlank(transM) + "," + WU.yesBlank(transW) 
		+ "," + WU.yesBlank(GQ) + "," + genderString()
		+ "," + age 
		+ "," + WU.yesBlank( kinky )
		+ "," + WU.yesBlank(lookM) + "," + WU.yesBlank(lookW) 
		+ "," + WU.yesBlank(lookTM) + "," + WU.yesBlank(lookTW)
		+ "," + WU.yesBlank(lookGQ) + "," + WU.yesBlank(lookNone)
		+ "," + genderLookString()
		+ "," + WU.writeLookKink(lookKink)
		+ "," + minAge + "," + maxAge;

		return outputString;
	}

	public String geekCode( boolean sayPrimaryStatus ) {
		String s = "a " + age + " yr old " + genderDesc();
		
		
		if ( kinky ) {
			s += " (kinky)";
		} else {
			s += " (not kinky)";
		}
	
		if ( sayPrimaryStatus ) {
			 s += noPrimary ? " with no current primary" : " with at least one primary";
		}
		
		s += " looking for " + minAge + "-" + maxAge + " yr old";
		
		if ( lookKink == LookKinkHow.EITHER ) {
			s += " kinky or not ";
		} else if ( lookKink == LookKinkHow.NONE) {
			s += " not kinky ";
		} else {
			s += " kinky ";
		}
		s += genderLookDesc();
		return s;
	}

	/*	boolean womanActive() {
		return womanActive != NO;
	}
	boolean manActive() {
		return manActive != NO;
	}
*/
	public int willDate( Person who ) {

		int bonus = 0;
		
		if ( ( who.kinky && (lookKink==LookKinkHow.NONE ) )
				|| (!who.kinky && (lookKink==LookKinkHow.ONLY ) ) ) {
			return 0;
		}
		if ( kinky == who.kinky) {
			bonus += 2;
		}
		
		if ( (who.woman && !lookW)
				|| (who.man && !lookM) 
				|| ( who.GQ && !lookGQ ) 
				|| ( who.transW && !lookTW )
				|| ( who.transM && !lookTM ) ) {
			return 0;
		}

		if ( lookNone ) {
			throw new RuntimeException( "Asking someone who doesn't want to date whether they will date!" );
		}
		
		//age check
		//         if ( who.ageOld < (minAge-5) || who.ageYoung > (maxAge+4) ) {
		if ( (who.age < minAge) || (who.age > maxAge) ) {
			return 0;
		}
		
		if ( who.age >= minAge + 5 && who.age <= maxAge - 5 ) {
			bonus += 2;
		}

		return 1 + bonus;
	}
	
	

	public void setLookGenders(String string) {
		for (String seeking_gender :  string.split(",") ) {
		    if (seeking_gender.equals("M")) {
		        lookM = true;
		    }
		    if (seeking_gender.equals("F")) {
		        lookW = true;
		    }
		    if (seeking_gender.equals("TM")) {
		        lookTM = true;
		        continue;
		    }
		    if (seeking_gender.equals("TF")){
		        lookTW = true;
		        continue;
		    }
		    if (seeking_gender.equals( "Q")) {
		        lookGQ = true;
		        continue;
		    }
		}	
	}

	public void setGenders(String string) {
		for (String gender :  string.split(",") ) {
	      if (gender.equals("M")) {
	    		man = true;
		        continue;
		    }
		    if (gender.equals("F")) {
		        woman = true;
		        continue;
		    }
		    if (gender.equals( "TM")) {
		        transM = true;
		        continue;
		    }
		    if (gender.equals("TF") ){
		        transW = true;
		        continue;
		    }
		    if (gender.equals("Q")) {
		       GQ = true;
		        continue;
		    }
		}	
	}



	public void setAgeRange(int min, int max) {
		minAge =min;
		maxAge =max;
	}


	public void setLookKinky(String lookKinkS) {
			if ( lookKinkS.equals("K")) {
				lookKink = LookKinkHow.ONLY;
			} else if (lookKinkS.equals("NK")) {
				lookKink = LookKinkHow.NONE;
			} else if (lookKinkS.equals("EI")) {
				lookKink = LookKinkHow.EITHER;
			}    
	}
	

	public void setPrimary(boolean b) {
		noPrimary = b;	
	}

	
}


